use criterion::{criterion_group, criterion_main, Criterion};
use trie::trie::{Trie, TrieNode};

fn trie_new_benchmark(c: &mut Criterion) {
    c.bench_function("trie_new", |b| b.iter(|| Trie::<i32>::new()));
}

fn trie_find_end_binary_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_find_end_binary", |b| b.iter(|| trie.find_end_binary(b"test")));
}

fn trie_num_entries_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_num_entries", |b| b.iter(|| trie.num_entries()));
}

fn trie_find_end_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_find_end", |b| b.iter(|| trie.find_end(b"test")));
}

fn trie_insert_rollback_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_insert_rollback", |b| b.iter(|| trie.insert_rollback(b"test")));
}

fn trie_remove_binary_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_remove_binary", |b| b.iter(|| trie.remove_binary(b"test")));
}

fn trie_lookup_binary_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_lookup_binary", |b| b.iter(|| trie.lookup_binary(b"test")));
}

fn trie_lookup_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_lookup", |b| b.iter(|| trie.lookup("test")));
}

fn trie_remove_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    trie.insert_binary(b"test", Some(42));
    c.bench_function("trie_remove", |b| b.iter(|| trie.remove(b"test")));
}

fn trie_insert_binary_benchmark(c: &mut Criterion) {
    let mut trie = Trie::<i32>::new();
    c.bench_function("trie_insert_binary", |b| b.iter(|| trie.insert_binary(b"test", Some(42))));
}

criterion_group!(
    benches,
    trie_new_benchmark,
    trie_find_end_binary_benchmark,
    trie_num_entries_benchmark,
    trie_find_end_benchmark,
    trie_insert_rollback_benchmark,
    trie_remove_binary_benchmark,
    trie_lookup_binary_benchmark,
    trie_lookup_benchmark,
    trie_remove_benchmark,
    trie_insert_binary_benchmark
);
criterion_main!(benches);